package cn.doitedu.javase.calculate_engine.commons;

import com.alibaba.fastjson2.JSON;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class EventBean {

    private int user_id;
    private String event_id;
    private long action_time;
    private Map<String,Integer> properties;


    public static void main(String[] args) {

        EventBean eventBean = new EventBean();
        eventBean.setUser_id(3);
        eventBean.setEvent_id("add_cart");
        eventBean.setAction_time(System.currentTimeMillis());

        HashMap<String, Integer> map = new HashMap<>();
        map.put("k1",200);
        map.put("k2",300);
        map.put("k3",100);

        eventBean.setProperties(map);


        // 将对象转成json
        // {"action_time":1707117164401,"event_id":"add_cart","properties":{"k1":200,"k2":300,"k3":100},"user_id":3}
        String jsonString = JSON.toJSONString(eventBean);
        System.out.println(jsonString);

    }

}
